<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="ctx" value="${'$'}{pageContext.request.contextPath}"/>

<html>
<head>
	<title>表管理</title>
	
	<script>
		${'$'}(document).ready(function() {
			//聚焦第一个输入框
				<c:if test="${'$'}{action=='create'}">
					${'$'}("#${firstPrimaryKey}").focus();
				</c:if>
				<c:if test="${'$'}{action=='update'}">
					${'$'}("#${firstPrimaryKey}").focus();
				</c:if>
			
			//为inputForm注册validate函数
			${'$'}("#inputForm").validate();
		});
	</script>
</head>

<body>
	<form id="inputForm" action="${'$'}{ctx}/${module}/${classAttrName}/${'$'}{action}" method="post" class="form-horizontal">
		
		<fieldset>
			<legend><small>${tableName}管理</small></legend>
	<#if fieldList?exists>
		<#list fieldList as field>
			<#if field.display=="Y">	
				<div class="control-group">	
					<label class="control-label">${field.columnLabel}:</label>
					<div class="controls">
					<#if field.javaColumnAttrName==firstPrimaryKey>
						<c:if test="${'$'}{action=='create'}">
						<input type="text" id="${firstPrimaryKey}" name="${firstPrimaryKey}" value="${'$'}{${classAttrName}.${firstPrimaryKey}}" class="input-large"  />
						</c:if>
						<c:if test="${'$'}{action=='update'}">
						<input type="hidden" name="${firstPrimaryKey}" value="${'$'}{${classAttrName}.${firstPrimaryKey}}" />
						<input type="text" value="${'$'}{${classAttrName}.${firstPrimaryKey}}" class="input-large"  disabled="disabled"/>
						</c:if>
					<#else>
						<#if field.javaColumnTypeName=='Date'>
							<c:if test="${'$'}{action=='update'}">
							<span class="help-inline" style="padding:5px 0px"><fmt:formatDate value="${'$'}{${classAttrName}.${field.javaColumnAttrName}}" pattern="yyyy年MM月dd日  HH时mm分ss秒" /></span>
							</c:if>
						<#else>
							<input type="text" id="${field.javaColumnAttrName}" name="${field.javaColumnAttrName}" value="${'$'}{${classAttrName}.${field.javaColumnAttrName}}" class="input-large required"/>
						</#if>
					</#if>
					</div>
				</div>
			</#if>
		</#list>
	</#if>
			<div class="form-actions">
				<input id="submit_btn" class="btn btn-primary" type="submit" value="提交"/>&nbsp;	
				<input id="cancel_btn" class="btn" type="button" value="返回" onclick="history.back()"/>
			</div>
		</fieldset>
	</form>
</body>
</html>